package com.lenovo.leos.filebrowser.netdisk;

import java.io.Serializable;

public class NetFile implements Serializable{
	
	private static final String TAG = "NetFile";

	private String msID = null;
	private String msName = null;
	private String msParent = null;
	private String msNewName = null;
	private Type mType = Type.invalid;

	enum Type {
		dir, file, invalid;
	}

	public NetFile(String id, String name, String parent, Type type) {
		if (null == id || 0 == id.trim().length() || null == name
				|| name.trim().length() == 0 || parent == null) {
			Log.e(TAG, "invalid parameter in NetFile");
			return;
		} else {
			msID = id;
			msName = name;
			mType = type;
			
			if ("/".equals(name)){
				msParent = "";
			}else if (!parent.endsWith("/"))
				msParent = parent + "/";
			else
				msParent = parent;
		}
	}

	public String getID() {
		return msID;
	}

	public String getName() {
		return msName;
	}

	public String getParent() {
		return msParent;
	}

	public boolean isDirectory() {
		return mType == Type.dir ? true : false;
	}

	public boolean isFile() {
		return mType == Type.file ? true : false;
	}

	public String getAbsolutePath() {
		Log.d(TAG, "the getAbsolutePath is =============" + msParent + msName);
		return msParent + msName;
		
//		if("/".equals(msName)){
//			Log.d(TAG, "the getAbsolutePath is =============" + msParent);
//			return msParent + msName;
//		}else{
//			Log.d(TAG, "the getAbsolutePath is =============" + msParent + msName);
//			return msParent + msName;
//		}
	}

	public boolean isHidden() {
		return false;  
	}

//	public String getNewName() {
//		if (!hasNewName()) {
//			return null;
//		} else {
//			return msNewName;
//		}
//	}
//
//	public boolean hasNewName() {
//		if (msNewName == null) {
//			return false;
//		} else {
//			return true;
//		}
//	}

	public boolean setNewName(String strNewName) {
		if (null == strNewName || strNewName.length() == 0) {
			return false;
		} else {
			msNewName = strNewName;
			return true;
		}
	}

}